package cn.kwq.project_manger.config;

import io.minio.MinioClient;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;


@Data
@Component
@Configuration
public class MinioConfig {

    @ApiModelProperty("endPoint是一个URL，域名，IPv4或者IPv6地址")
    @Value("${minio.endpoint}")
    private String endpoint;

    @ApiModelProperty("accessKey类似于用户ID，用于唯一标识你的账户")
    @Value("${minio.accessKey}")
    private String accessKey;

    @ApiModelProperty("secretKey是你账户的密码")
    @Value("${minio.secretKey}")
    private String secretKey;


    @ApiModelProperty("默认存储桶")
    @Value("${minio.bucketName}")
    private String bucketName;


    public String getUrl(){
        return this.endpoint;
    }


    @Bean
    public MinioClient getMinioClient() {
        MinioClient minioClient = MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey,secretKey)
                .build();
        return minioClient;
    }
}
